package com.bw.house.adapter

import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bw.house.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class ItemAdapter(private val adapter: HouseAdapter) :BaseQuickAdapter<String,BaseViewHolder>(R.layout.item_layout) {

    private var isShow:Boolean=false
    override fun convert(holder: BaseViewHolder, item: String) {
        holder.setText(R.id.type,item)

        val house=holder.getView<RecyclerView>(R.id.house)
        holder.getView<ImageView>(R.id.open).apply {
            setOnClickListener {
                isShow=!isShow
                if(isShow) house.visibility=View.VISIBLE else house.visibility=View.GONE
            }
        }
        house.layoutManager=LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false)
        house.adapter=adapter

    }
}